import http from '@/utils/http';
//购物车列表类型
export type ICartListData = CartItem[];
//单个商品类型
export interface CartItem {
  id: number;
  userId: string;
  skuId: number;
  cartPrice: number;
  skuNum: number;
  imgUrl: string;
  skuName: string;
  isChecked: number;
  skuPrice: number;
}

// 获取购物车列表
export const GetCartList = () => {
  return http.get<ICartListData>('/api/cart/cartList');
};
// 切换商品选中状态
export const CheckCartOne = (skuId: number, isChecked: number) => {
  return http.get<null>(`/api/cart/checkCart/${skuId}/${isChecked}`);
};
// 购物车商品全选
export const BatchCheckCart = (isChecked: number, skuIdList: number[]) => {
  return http.post<null>(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};
// 删除购物车单个商品
export const DeleteCart = (skuId: number) => {
  return http.delete<null>(`/api/cart/deleteCart/${skuId}`);
};
// 添加到购物车
export const addToCart = (skuId:number,skuNum:number)=>{
  return http.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
}